package com.cjl.host.config;

import com.cjl.host.interceptor.HostFirstInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author cjl
 * @version v1.0
 * @description TODO
 * @createTime 2023/2/16 11:43
 */

@Slf4j
@Configuration
public class HostWebMVCConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new HostFirstInterceptor())
                .addPathPatterns("/**") //拦截所有请求
                .excludePathPatterns("/swagger-resources/**")  //放行所有knife页面请求
                .excludePathPatterns("/doc.html/**")  //放行所有knife页面请求
                .excludePathPatterns("/api/host/login_auth/**");  //放行登录/注册操作
        log.info("添加HostFirstInterceptor拦截器到spring容器中。。。");
    }

}
